package String;

public class _657_JudgeRouteCircle {
    int horizontal = 0;
    int vertical = 0;
    public boolean judgeCircle(String moves) {
        int length = moves.length();
        for(int i=0;i<length;i++) {
            circlecalculate(moves.charAt(i));
        }
        return ((horizontal==0)&&(vertical==0));
    }

    public void circlecalculate(char x) {
        switch (x) {
            case 'U':horizontal++;break;
            case 'D':horizontal--;break;
            case 'L':vertical++;break;
            case 'R':vertical--;break;
        }
    }
}
